package message.types.stalker;

import java.io.IOException;

import message.visitor.MessageVisitor;
import network.e2e.FrameReader;
import stalker.Stalker;

/**
 * Requests by a client to be registered in a room
 */

public class RegisterRequest extends StalkerMessage {
  
  /**
   * Backwards compatibility
   */
  public RegisterRequest(Stalker client, Stalker destination) {
    super(client, destination, client);
  }
  
  public RegisterRequest(Stalker client, Stalker destination, Stalker stalker) {
    super(client, destination, stalker);
  }
  
  public RegisterRequest(Stalker client, Stalker destination, FrameReader reader) throws IOException {
    super(client, destination, reader);
  }
  
  public Stalker getStalker() {
    return this.getCredential();
  }

  @Override
  public <T> T accept(MessageVisitor<T> visitor) {
    return visitor.visit(this);
  }

  @Override
  public String toString() {
    return ("RegisterRequest by : " + this.getClient() + " for " + this.getCredential());
  }

  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof RegisterRequest)) {
      return false;
    }
    return super.contentEquals(obj);
  }

}
